commonlibsse_ng\re\i/
INISettingCollection.rs

1use core::ffi::CStr;
2
3use crate::re::Setting::Setting;
4use crate::re::SettingCollectionList::{SettingCollectionList, SettingCollectionListVtbl};
5use crate::re::offsets_rtti::RTTI_INISettingCollection;
6use crate::re::offsets_vtable::VTABLE_INISettingCollection;
7use crate::rel::id::VariantID;
8
9#[derive(Debug)]
10#[repr(C)]
11pub struct INISettingCollection {
12    pub __base: SettingCollectionList<Setting>, // 0x000
13}
14const _: () = {
15    assert!(core::mem::offset_of!(INISettingCollection, __base) == 0x00);
16    assert!(core::mem::size_of::<INISettingCollection>() == 0x128);
17};
18
19impl INISettingCollection {
20    /// Address & Offset of the runtime type information (RTTI) identifier.
21    pub const RTTI: VariantID = RTTI_INISettingCollection;
22
23    /// Address & Offset of the virtual function table.
24    pub const VTABLE: [VariantID; 1] = VTABLE_INISettingCollection;
25
26    /// Gets the singleton instance of `INISettingCollection`.
27    #[commonlibsse_ng_derive_internal::relocate(
28        cast_as = "*mut *mut INISettingCollection",
29        default = "None",
30        deref_once,
31        id(se = 524557, ae = 411155)
32    )]
33    #[inline]
34    pub fn get_singleton() -> Option<&'static INISettingCollection> {
35        |deref_type: DerefType| unsafe { deref_type.as_ref() }
36    }
37
38    pub fn get_setting(&self, name: &CStr) -> Option<&Setting> {
39        for setting in &self.__base.settings {
40            let setting = match unsafe { setting.as_ref() } {
41                Some(setting) => setting,
42                None => continue,
43            };
44            let setting_name = match setting.get_name() {
45                Some(name) => name,
46                None => continue,
47            };
48
49            if name == setting_name {
50                return Some(setting);
51            }
52        }
53
54        None
55    }
56}
57
58/// The virtual function table for `INIPrefSettingCollection`.
59///
60/// This struct defines function pointers to simulate the C++ virtual functions.
61#[repr(C)]
62pub struct INISettingCollectionVtbl {
63    pub __base: SettingCollectionListVtbl<Setting>,
64}